Skip to content

docs(id): cost & limits guardrails decision record for serverless storage (#5868) - #7591

Merged
dezren39 merged 1 commit into
mainfrom
queue/12840-5868-cost-limits
Nov 16, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/12840-5868-cost-limits

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

What this is

The decision record owed by #5868 (follow-on to #5681): how id handles quotas, backpressure and operator-visible warnings when a world approaches a D1 or Turso ceiling.

Closes #5868.

📄 doc/2026-11-08_decision_id5868_cost_limits_guardrails.md

The decision

A derived account+world budget meter with a fixed degrade ladder and typed refusals:

  1. Meters at account and world/shard scope (both vendors' quotas are account-scoped), advanced from the per-query counters the backends already return — D1 meta.rows_read/meta.rows_written, Turso's SQL-over-HTTP rows_read/rows_written — never from aggregate scans over the journal.
  2. Budgets are configuration, expressed as fractions of the plan ceiling. No vendor number is hardcoded.
  3. Four-state ladder normal → warning → degraded → refused per account, world and shard, with hysteresis (warn 50%, degraded 75%, journal-only reserve 90%, refuse 100%) and burn-rate projection.
  4. Fixed degrade order: advisory surfaces → bulk non-journal reads → deferrable writes → never journal appends.
  5. Typed refusals, with BLOCKED / D1 daily-limit / D1 overloaded mapped to distinct states.
  6. Operator-visible guardrail state on the world status, with time-to-reset.
  7. Account-scoped quotas with per-world allocations; per-world totals summed across shards.

Alternatives rejected

Vendor-only (fails closed/uncapped/at the wrong call site), a metering proxy on the journal path, static capacity planning alone, and a single global undifferentiated account budget.

Evidence in the record

  • D1: free tier fails closed since 2026-09-01; Workers Paid has no hard spending cap; per-database single-threaded throughput; 10 GB hard database cap; 50 MB result cap.
  • Turso: BLOCKED on quota; overages opt-in per plan; row-scan accounting; monthly plan quotas and sync allowances.
  • Cost arithmetic at the three scales from the recorded vendor rates.

Flags for the parent (#5681) — not forked, recorded

  1. D1's uncapped paid overage is a live cost risk for placement-by-heat; billing ceilings belong in the placement policy.
  2. Turso BLOCKED mid-append needs the degrade-not-fail ruling (interim answer: the reserve keeps the journal writable through 90–100%).
  3. Turso plan continuity is unresolved (Supabase acquisition); plan terms are configuration with a review date.
  4. D1's 10 GB hard cap means a hot shard must split — the guardrail needs bytes-to-cap warnings.
  5. D1 read replication adds no charge but no write capacity.

Verification

Docs-only change. git diff --check clean. Every vendor number is cited to the page it came from, read 2026-11-08, and the record states explicitly that those numbers are configuration rather than constants.

Scope

No implementation. Splits, if any, are filed and linked on #5868 rather than grown here.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…rage (#5868)

Records the chosen guardrail shape (derived account+world meter, four-state
ladder with hysteresis, fixed degrade order that protects journal appends,
typed refusals, operator-visible state), the alternatives rejected, the cost
model at single-user / small-community / large-world scale, and the invariants
implementation must hold. Flags five points that constrain or change parent
#5681's direction rather than silently forking it.
@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 09:05
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e68bf887-5cd1-4249-9fee-6cfdf21aa21b
Commits

Reviewing files that changed from the base of the PR and between 62e722d and 469331f.

Files selected for processing: 1

  • doc/2026-11-08_decision_id5868_cost_limits_guardrails.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T09:07:25.088173Z 469331f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: done
task: 17317
lane: code-a
worker: repo-worker-code
note: Shepherd pass in task 17317: MERGED on its merits. Fresh verification this shift (2026-11-16): PR was OPEN, MERGEABLE, head 469331f, no held/user-owned/do-not-merge labels, no Codex reviews to disposition, and its single file (doc/2026-11-08_decision_id5868_cost_limits_guardrails.md, the #5868 cost & limits guardrails decision record) was not present on main. Merged: merge commit 06d9df9 at 2026-11-16T11:03:05Z. Task 17317 completes as fixed_merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id: design: cost & limits guardrails (serverless storage) (from #5681)

1 participant